<template>
  <div class="w banner">
    <img src="@/assets/img/algo-service/detail-banner.jpg" class="banner__bg" draggable="false" />
    <div class="title-and-type">
      <div class="title">{{ algoItem?.algorithmName }}</div>
      <div v-if="algoItem?.typeAndNames?.length" class="type-list">
        <div v-for="typeItem in algoItem?.typeAndNames" :key="typeItem.name" class="type">{{ typeItem.name }}</div>
      </div>
    </div>
    <div class="des">
      {{ algoItem?.algorithmDescribe }}
    </div>
    <div class="tag-list">
      <div v-for="tag in algoItem?.labelAndNames" :key="tag.name" class="tag">{{ tag.name }}</div>
    </div>
    <img v-if="algoItem?.downloadImageUrl" :src="algoItem?.downloadImageUrl" class="algo-img" draggable="false" />
  </div>
</template>

<script lang="ts" setup>
  import { inject } from 'vue'

  import { AlgoItem } from '../index.vue'

  const algoItem = inject('algoItem') as AlgoItem
</script>

<style lang="less" scoped>
  @import '@/styles/mixins.less';

  .banner {
    position: relative;
    height: 240px;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    box-shadow: 0 1px 5px 0 rgba(66, 132, 237, 0.2);

    .banner__bg {
      position: absolute;
      top: 50%;
      left: 50%;
      width: 100%;
      height: 100%;
      border-radius: 12px;
      transform: translate(-50%, -50%);
      object-fit: cover;
    }

    .title-and-type {
      position: absolute;
      top: 60px;
      left: 80px;
      z-index: 5;
      display: flex;
      align-items: center;

      .title {
        max-width: 900px;
        font-size: 36px;
        font-family: 'Alimama FangYuanTi VF';
        color: #002259;
        font-style: normal;
        font-weight: 600;
        line-height: normal;
        letter-spacing: 0.72px;

        .fw500();
      }

      .type-list {
        padding: 0 16px;
        margin-left: 32px;
        height: 30px;
        color: rgba(3, 42, 105, 0.7);
        background: rgba(0, 0, 0, 0.02);
        border: 1px solid rgba(0, 0, 0, 0.05);
        border-radius: 100px;
        font-style: 14px;
        .fc();

        .type {
          display: flex;
          align-items: center;

          & + .type {
            margin-left: 8px;

            &::before {
              left: 16px;
              display: block;
              margin-right: 8px;
              width: 1px;
              height: 16px;
              background-color: rgba(0, 0, 0, 0.05);
              content: '';
            }
          }
        }
      }
    }

    .des {
      position: absolute;
      top: 127px;
      left: 80px;
      // 三行省略
      display: -webkit-box;
      overflow: hidden;
      width: 630px;
      height: 48px;
      font-size: 16px;
      text-overflow: ellipsis;
      white-space: normal;
      color: rgba(25, 25, 48, 0.75);
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 4;
      word-break: break-all;
      font-weight: 400;
      line-height: 22px;
    }

    .tag-list {
      position: absolute;
      top: 172px;
      left: 80px;
      display: flex;
      font-weight: 400;
      font-size: 16px;
      color: rgba(24, 104, 233, 1);
      line-height: 24px;

      .tag {
        padding: 3px 6px;
        background: rgba(24, 104, 233, 0.08);
        border-radius: 6px;

        & + .tag {
          margin-left: 12px;
        }
      }
    }

    .algo-img {
      position: absolute;
      right: 294px;
      bottom: 12px;
      z-index: 3;
      width: 252px;
      height: 212px;
      object-fit: cover;
    }
  }
</style>
